package com.borya.action.mobile;

import org.apache.log4j.Logger;

import com.alibaba.fastjson.JSONObject;
import com.borya.action.BaseAction;
import com.borya.framework.annotation.Action;
import com.borya.framework.annotation.Autowired;
import com.borya.framework.annotation.JsonResult;
import com.borya.framework.annotation.UrlMapping;
import com.borya.framework.core.ServerRequest;
import com.borya.framework.core.ServerResponse;
import com.borya.service.mobile.UploadImgFileService;

/**
 * @author rxg
 * @date 2020/2/20 文件流图片上传
 */
@UrlMapping("/c/uploadImgFile/")
@Action
public class UploadImgFileAction extends BaseAction {

	private Logger log = Logger.getLogger(getClass());
	@Autowired("uploadImgFileService")
	private UploadImgFileService uploadImgFileService;

	/**
	 * 文件流上传图片
	 *
	 * @param request
	 *            请求
	 * @param response
	 *            响应
	 * @return
	 */
	@UrlMapping("upload")
	@JsonResult
	public String upload(ServerRequest request, ServerResponse response) {
		JSONObject json = getJson(request);
		String result = uploadImgFileService.upload(getUser(request), request, json);
		log.info("OUT :" + result);
		return result;
	}
}
